﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Musicman.Client2.Components
{
    class ProgressLabel : Label
    {
        private Color SINGLE_GRADIENT_COLOR1 = Color.Orange;
        private Color SINGLE_GRADIENT_COLOR2 = Color.WhiteSmoke;
        private int percentage;

        public ProgressLabel()
            : base()
        {
        }

        protected  override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            SolidBrush sb = new SolidBrush(Color.Wheat);
            Pen borderPen = new Pen(sb);
            float width = (float)this.Width * (float)this.percentage / 100f;
            if (width != 0)
            {
                Rectangle rect = new Rectangle(0, 0, (int)width, this.Height);
                LinearGradientBrush lgb = new LinearGradientBrush(rect,
                                    SINGLE_GRADIENT_COLOR1, SINGLE_GRADIENT_COLOR2, 90f);
                g.FillRectangle(lgb, rect);
            }
            base.OnPaint(e);
        }

        public int Percentage
        {
            get { return percentage; }
            set 
            {
                if (value != percentage)
                {
                    percentage = value;
                    Refresh();
                }
            }
        }
    }
}
